/**
 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
 */
// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作
const install = (Vue, vm) => {
	
	// 参数配置对象
	const config = vm.vuex_config;
	
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		
		// 注册账号
		register: (params = {}) => vm.$u.postJson(config.adminPath+'/app/nk/member/register', params),
		// 绑卡
		bindCard: (params = {}) => vm.$u.postJson(config.adminPath+'/app/nk/member/bindCard', params),
		// 我的有机卡列表
		myCard: (params = {}) => vm.$u.postJson(config.adminPath+'/app/nk/member/myCard', params),
		
		// 有机卡进去的详情
		cardInfo: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/plan/cardInfo', params),
		
		// app/nk/plan/cardInfo?cardId=有机卡的ID
		
		// code换用户信息
		getOpenid: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/member/getOpenid', params),
		// 获取短信验证码
		sendCode: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/member/sendCode', params),
		
		// 地址相关接口
		
		// 地址-我的全部地址
		addresslist: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/address/list', params),
		// 地址-删除
		deleteAddress: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/address/deleteAddress', params),
		// 地址-设置默认
		setMoren: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/address/setMoren', params),
		// 地址-添加或修改
		saveOrUpdate: (params = {}) => vm.$u.postJson(config.adminPath+'/app/nk/address/saveOrUpdate', params),
		// 查看单个地址
		singleInfo: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/address/info', params),
		
		
		
		// 计划相关接口
		// 计划-查询计划列表
		cardPlanList: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/plan/cardPlanList', params),
		// 计划-修改单个计划
		updatePlan: (params = {}) => vm.$u.postJson(config.adminPath+'/app/nk/plan/updatePlan', params),
		// 计划-创建发货计划
		generatePlans: (params = {}) => vm.$u.postJson(config.adminPath+'/app/nk/plan/generatePlans', params),
		// 计划-查询某个计划(修改用)
		planDetail: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/plan/planDetail', params),
		
		// 暂停或开始发货
		startOrStopFahuo: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/plan/startOrStopFahuo', params),
		
		
		// app/nk/plan/orderDetailByPlanId?planId=计划ID
		
		orderDetailByPlanId: (params = {}) => vm.$u.get(config.adminPath+'/app/nk/plan/orderDetailByPlanId', params),
		
		
		
		
		// 基础服务：登录登出、身份信息、菜单授权、切换系统、字典数据等
		lang: (params = {}) => vm.$u.get('/lang/'+params.lang),
		index: (params = {}) => vm.$u.get(config.adminPath+'/mobile/index', params),
		getUserInfo: (params = {}) => vm.$u.get(config.adminPath+'/mobile/user/getUserInfo', params),
		login: (params = {}) => vm.$u.post(config.adminPath+'/mobile/login/loginByPassword', params),
		// sendCode: (params = {}) => vm.$u.post(config.adminPath+'/mobile/login/sendCode', params),
		registerUser: (params = {}) => vm.$u.post(config.adminPath+'/mobile/user/registerUser', params),
		//首页相关api
		getIndexCardInfo: (params = {}) => vm.$u.get(config.adminPath+'/mobile/index/getIndexCardInfo', params),
		getM2mOrderFlowList: (params = {}) => vm.$u.get(config.adminPath+'/mobile/index/getM2mOrderFlowList', params),
		//获取卡可购买套餐包
		getM2mOrderPackageList: (params = {}) => vm.$u.get(config.adminPath+'/mobile/index/getM2mOrderPackageList', params),
		
		logout: (params = {}) => vm.$u.get(config.adminPath+'/mobile/login/logout', params),
		authInfo: (params = {}) => vm.$u.get(config.adminPath+'/authInfo', params),
		menuTree: (params = {}) => vm.$u.get(config.adminPath+'/menuTree', params),
		switchSys: (params = {}) => vm.$u.get(config.adminPath+'/switch/'+params.sysCode),
		dictData: (params = {}) => vm.$u.get(config.adminPath+'/system/dict/data/type/'+params.dictType),
		
		// 账号服务：验证码接口、忘记密码接口、注册账号接口等
		validCode: (params = {}) => vm.$u.getText('/validCode', params),
		getFpValidCode: (params = {}) => vm.$u.post('/account/getFpValidCode', params),
		savePwdByValidCode: (params = {}) => vm.$u.post('/account/savePwdByValidCode', params),
		getRegValidCode: (params = {}) => vm.$u.post('/account/getRegValidCode', params),
		saveRegByValidCode: (params = {}) => vm.$u.post('/account/saveRegByValidCode', params),
		
		// APP公共服务
		upgradeCheck: () => vm.$u.post('/app/upgrade/check', {appCode: config.appCode, appVersion: config.appVersion}),
		commentSave: (params = {}) => vm.$u.post('/app/comment/save', params),
		
		// 个人信息修改
		user: {
			saveUserInfo: (params = {}) => vm.$u.post(config.adminPath+'/mobile/user/saveUserInfo', params),
			infoSavePwd: (params = {}) => vm.$u.put(config.adminPath+'/system/user/profile/updatePwd', params),
			infoSavePqa: (params = {}) => vm.$u.post(config.adminPath+'/sys/user/infoSavePqa', params),
		},
		
		// 员工用户查询
		empUser: {
			listData: (params = {}) => vm.$u.get(config.adminPath+'/sys/empUser/listData', params),
		},
		
		// 组织机构查询
		office: {
			treeData: (params = {}) => vm.$u.get(config.adminPath+'/sys/office/treeData', params),
		},
		
		// 增删改查例子
		testData: {
			form: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/form', params),
			list: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/listData', params),
			save: (params = {}) => vm.$u.postJson(config.adminPath+'/test/testData/save', params),
			disable: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/disable', params),
			enable: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/enable', params),
			delete: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/delete', params),
		},
		
	};
	
}

export default {
	install
}